package com.company;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

    public static void main(String[] args) {
	// write your code here
        String userName = "yanqinghe";//用户名
        String passWord = "yanqinghe123";//密码

        Map<String, Object> requestParamsMap = new HashMap<String, Object>();//POST参数

        ReadHTML read  = new ReadHTML();//新建读取对象
        List<Data> dataList = read.writeHTMl();//从htm文件中获取数据

        //循环Post每一条知识
        for(int i =0;i<dataList.size(); i++){

            requestParamsMap = read.Lis2Data(dataList.get(i));
            WebService webService = new WebService();
            try {
                String result = webService.Login(userName,passWord);
                String result2 =webService.viewPage();
                String result3 =webService.submitForm(requestParamsMap);
                if(result3.trim().equals("ok")){
                    System.out.println(i +"    成功提交" + result3);
                }else{
                    System.out.println(i +"    提交失败" + result3);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
